package com.cdxy.config.schedule;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.Executors;

/**
 * Esion
 * 2019-07-25 10:48
 * 启用多线程定时任务
 * (实现SchedulingConfigurer接口，重写configureTasks方法)
 */
@Configuration
public class ScheduleConfig implements SchedulingConfigurer {
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        //设定一个数量5的定时任务线程池
        taskRegistrar.setScheduler(Executors.newScheduledThreadPool(5));
    }
}
